package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean checkedUser(String username) throws SQLException {
        return false;
    }

    @Override
    public int registerUser(User user) throws SQLException {
        return 0;
    }

    @Override
    public int activeUser(String code) throws SQLException {
        return 0;
    }

    @Override
    public User login(String username, String password) throws SQLException {
        return userMapper.login(username,password);
    }

    @Override
    public List<User> findAllUser(int startNum,int rows ) {
        return userMapper.showToPage(startNum,rows);
    }

    @Override
    public int findTotal() {
        return userMapper.findTotal();
    }

    @Override
    public List<User> showToPage(int startNum, int rows) {
        return userMapper.showToPage(startNum,rows);
    }

    @Override
    public boolean addUser(User user) {
        int result = userMapper.addUser(user);
        return result > 0;
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int delUserByUid(Integer uid) {
        return userMapper.delUserByUid(uid);
    }
}
